#!/bin/sh
# Create the build system.

set -e -x

# Generate stubs for translations.
langs=`find po/doc -type f -name 'guix-manual*.po' \
        | sed -e 's,.*/guix-manual\.,,;s,\.po$,,'`
for lang in ${langs}; do
    if [ ! -e "doc/guix.${lang}.texi" ]; then
	echo "@setfilename guix.${lang}.info" > "doc/guix.${lang}.texi"
	echo "@include version-${lang}.texi" >> "doc/guix.${lang}.texi"
	# Ensure .po file is newer.
	touch "po/doc/guix-manual.${lang}.po"
    fi
done
langs=`find po/doc -type f -name 'guix-cookbook*.po' \
        | sed -e 's,.*/guix-cookbook\.,,;s,\.po$,,'`
for lang in ${langs}; do
    if [ ! -e "doc/guix-cookbook.${lang}.texi" ]; then
	echo "@setfilename guix-cookbook.${lang}.info" > "doc/guix-cookbook.${lang}.texi"
	# Ensure .po file is newer.
	touch "po/doc/guix-cookbook.${lang}.po"
    fi
done

autoreconf -vfi

# Replace Automake's build-aux/mdate-sh with build-aux/mdate-from-git, our
# own, reproducible version.
chmod +w build-aux/mdate-sh
rm -f build-aux/mdate-sh
ln -s mdate-from-git.scm build-aux/mdate-sh
